<template>
  <div>
    <el-container>
      <el-header>&nbsp;人力资源管理系统</el-header>
      <el-container class="container">
        <el-aside width="300px">
          <Menu>

          </Menu>
        </el-aside>
        <el-container>
          <el-main
              ref="SalaryDistributionQueryDetail"
          >
            <el-row>
              <el-col :span="22">
                <div class="grid-content bg-purple-dark">
                  <span>
                    薪酬发放详情
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content">
                  <span>
                    <el-button type="primary" round @click="back">返回</el-button>
                  </span>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    薪酬发放单编号
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  {{salaryDistributionFile.slistId}}
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    登记人
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                 {{salaryDistributionFile.registrant}}
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    登记日期
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  {{salaryDistributionFile.registerTime}}
                </div>
              </el-col>

            </el-row>
            <el-row>
              <el-col :span="3">
                <div class="grid-content bg-purple">
                  <span>
                    I级机构
                  </span>
                </div>
              </el-col>
              <el-col :span="3">
                <div class="grid-content bg-purple-light">
                  <el-select v-model="salaryDistributionFile.forgId" disabled placeholder="请选择" style="width: 100%">
                    <el-option
                        v-for="item in salaryDistribution.FirstOrganization"
                        :key="item.forgId"
                        :label="item.forgName"
                        :value="item.forgId"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>
              <el-col :span="3">
                <div class="grid-content bg-purple">
                  <span>
                    II级机构
                  </span>
                </div>
              </el-col>
              <el-col :span="3">
                <div class="grid-content bg-purple-light">
                  <el-select v-model="salaryDistributionFile.sorgId" disabled placeholder="请选择" style="width: 100%">
                    <el-option
                        v-for="item in salaryDistribution.SecondOrganization"
                        :key="item.sorgId"
                        :label="item.sorgName"
                        :value="item.sorgId"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>
              <el-col :span="3">
                <div class="grid-content bg-purple">
                  <span>
                    III级机构
                  </span>
                </div>
              </el-col>
              <el-col :span="3">
                <div class="grid-content bg-purple-light">
                  <el-select v-model="salaryDistributionFile.torgId" disabled placeholder="请选择" style="width: 100%">
                    <el-option
                        v-for="item in salaryDistribution.ThirdOrganization"
                        :key="item.torgId"
                        :label="item.torgName"
                        :value="item.torgId"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>
              <el-col :span="3">
                <div class="grid-content bg-purple">
                  <span>
                    总额
                  </span>
                </div>
              </el-col>
              <el-col :span="3">
                  {{salaryDistributionFile.totalSalary}}
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    档案编号
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    姓名
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    基本工资
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    交通补助
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    午餐补助
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    通勤补助
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    养老保险
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    失业保险
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    医疗保险
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    住房公积金
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    奖励金
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    扣除金
                  </span>
                </div>
              </el-col>
            </el-row>
            <el-row v-for="(salaryDistributionDetail, index) in salaryDistributionDetails" :key="index">
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.fileId}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.name}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.basic}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.transportation}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.lunch}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.communication}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.endowment}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.unemployment}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.medical}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.providentFund}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  {{salaryDistributionDetail.bounty}}
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  {{salaryDistributionDetail.deduction}}
                </div>
              </el-col>
            </el-row>


          </el-main>
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import{ defineComponent, ref }from 'vue'
import {
  Location,
  Document,
  Menu as IconMenu,
  Setting,
} from '@element-plus/icons-vue'
import Menu from "@/components/Menu";
export default defineComponent({
  name: "SalaryDistributionQueryDetail",
  components: {
    Menu,
    Location,
    Document,
    Setting,
    IconMenu,
  },
  setup() {
    const activeNames = ref(['1'])
    const handleChange = (val) => {
      console.log(val)
    }
    return {
      activeNames,
      handleChange,
    }
  },
  data() {
    return {
      salaryDistributionFile: {
        slistId: '',
        forgId: '',
        sorgId: '',
        torgId: '',
        registrant: '',
        registerTime: '',
        totalSalary:'',
      },
      salaryDistributionDetails: [],
      salaryDistribution: {
        FirstOrganization: null,
        SecondOrganization: null,
        ThirdOrganization: null,
        bounty:'',
        deduction:'',
      },
    }
  },
  methods: {
    back() {
      this.$router.back();
    },
    getFirstOrg() {
      this.axios.get('/selectFirstOrg').then(res =>{
        const _this = this
        _this.salaryDistribution.FirstOrganization = res.data.data
      }).then(res =>{
        this.getSecondOrg()
      })
    },
    getSecondOrg() {
      this.axios.get('/selectSecondOrg/'+ this.salaryDistributionFile.forgId).then(res =>{
        const _this = this
        _this.salaryDistribution.SecondOrganization = res.data.data
      }).then(res =>{
        this.getThirdOrg()
      })
    },
    getThirdOrg() {
      this.axios.get('/selectThirdOrg/'+ this.salaryDistributionFile.sorgId).then(res =>{
        const _this = this
        _this.salaryDistribution.ThirdOrganization = res.data.data
      })
    },
  },
  created() {
    const distributedId = this.$route.params.distributedId
    const _this = this
    if(distributedId){
      this.axios.get('/distributed/SalaryDistributionQuery/'+distributedId).then(res=>{
        const salaryDistribution = res.data.data
        _this.salaryDistributionFile.slistId=salaryDistribution.slistId
        _this.salaryDistributionFile.registrant=salaryDistribution.registrant
        _this.salaryDistributionFile.forgId=salaryDistribution.forgId
        _this.salaryDistributionFile.sorgId=salaryDistribution.sorgId
        _this.salaryDistributionFile.torgId=salaryDistribution.torgId
        _this.salaryDistributionFile.registerTime=salaryDistribution.registerTime
        _this.salaryDistributionFile.totalSalary=salaryDistribution.totalsalary
      }).then(res =>{
        this.getFirstOrg()
      })
    }
    if(distributedId){
      this.axios.get('/distributed/SalaryDistributionQueryDetail/'+distributedId).then(res=>{
        _this.salaryDistributionDetails = res.data.data
        console.log(_this.salaryDistributionDetails)
      })
    }
  }

})
</script>

<style scoped>
.el-header{
  background-color: #409EFF;
  color: #e9eef3;
  text-align: left;
  line-height: 60px;
  font-size: 30px;
}
.el-aside {
  background-color: #d3dce6;
  color: var(--el-text-color-primary);
  text-align: center;
  /*line-height: 860px;*/
}

.el-main {
  background-color: #e9eef3;
  color: var(--el-text-color-primary);
  text-align: center;
  line-height: 30px;
}

body > .el-container {
  margin-bottom: 400px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-row {
  margin-bottom: 20px;
}

.el-row :last-child {
  margin-bottom: 0;
}

.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

.high-row{
  min-height: 200px;
}

.container{
  min-height: 860px;
}

.line {
  width: 70%;
}

.line div {
  width: 100%;
  height: 0;
  border-top: 1px solid var(--el-border-color-base);
}

</style>